﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.StockModule;
using Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Supplier

    /// <summary>
    /// Supplier object for NHibernate mapped table 'Supplier'.
    /// </summary>
    [Serializable]
    public class Supplier : Persistent<string>
    {
        #region Member Variables

        protected SystemIdentifier.SupplierNature _nature;
        protected string _name;
        protected SupplierType _type;
        protected string _contact;
        protected string _telephone;
        protected string _mobile;
        protected string _fax;
        protected string _email;
        protected Area _area;
        protected string _address;
        protected string _addressEnglish;
        protected string _deliveryAddress1;
        protected string _deliveryAddress2;
        protected SystemIdentifier.PayType _payType;
        protected decimal _discountRate;
        protected int _payDay;
        protected decimal _creditLimit;
        protected decimal _defaultTaxRate;
        protected string _remark;
        protected Role _employeeRole;
        protected Corporation _corporation;
        protected IList<PurchaseOrder> _purchaseOrders;
        protected IList<Pay> _pays;
        protected IList<PurchaseReturn> _purchaseReturns;
        protected IList<StockInOut> _stockIns;

        #endregion

        #region Constructors

        public Supplier() { }

        public Supplier(string id, SystemIdentifier.SupplierNature nature, string name, SupplierType type, string contact, string telephone, string mobile, string fax, string email, Area area, string address, string addressEnglish, string deliveryAddress1, string deliveryAddress2, SystemIdentifier.PayType payType, decimal discountRate, int payDay, decimal creditLimit, decimal defaultTaxRate, string remark, DateTime createDate, DateTime modifyDate, int editUser, Role employeeRole, Corporation corporation)
        {
            this.Id = id;
            this._nature = nature;
            this._name = name;
            this._type = type;
            this._contact = contact;
            this._telephone = telephone;
            this._mobile = mobile;
            this._fax = fax;
            this._email = email;
            this._area = area;
            this._address = address;
            this._addressEnglish = addressEnglish;
            this._deliveryAddress1 = deliveryAddress1;
            this._deliveryAddress2 = deliveryAddress2;
            this._payType = payType;
            this._discountRate = discountRate;
            this._payDay = payDay;
            this._creditLimit = creditLimit;
            this._defaultTaxRate = defaultTaxRate;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._employeeRole = employeeRole;
            this._corporation = corporation;
        }

        #endregion

        #region Public Properties


        public virtual SystemIdentifier.SupplierNature Nature
        {
            get { return _nature; }
            set { _nature = value; }
        }

        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual SupplierType Type
        {
            get { return _type; }
            set { _type = value; }
        }

        public virtual string Contact
        {
            get { return _contact; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Contact", value, value.ToString());
                _contact = value;
            }
        }

        public virtual string Telephone
        {
            get { return _telephone; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Telephone", value, value.ToString());
                _telephone = value;
            }
        }

        public virtual string Mobile
        {
            get { return _mobile; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Mobile", value, value.ToString());
                _mobile = value;
            }
        }

        public virtual string Fax
        {
            get { return _fax; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Fax", value, value.ToString());
                _fax = value;
            }
        }

        public virtual string Email
        {
            get { return _email; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());
                _email = value;
            }
        }

        public virtual Area Area
        {
            get { return _area; }
            set { _area = value; }
        }

        public virtual string Address
        {
            get { return _address; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for Address", value, value.ToString());
                _address = value;
            }
        }

        public virtual string AddressEnglish
        {
            get { return _addressEnglish; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for AddressEnglish", value, value.ToString());
                _addressEnglish = value;
            }
        }

        public virtual string DeliveryAddress1
        {
            get { return _deliveryAddress1; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress1", value, value.ToString());
                _deliveryAddress1 = value;
            }
        }

        public virtual string DeliveryAddress2
        {
            get { return _deliveryAddress2; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for DeliveryAddress2", value, value.ToString());
                _deliveryAddress2 = value;
            }
        }

        public virtual SystemIdentifier.PayType PayType
        {
            get { return _payType; }
            set { _payType = value; }
        }

        public virtual decimal DiscountRate
        {
            get { return _discountRate; }
            set { _discountRate = value; }
        }

        public virtual int PayDay
        {
            get { return _payDay; }
            set { _payDay = value; }
        }

        public virtual decimal CreditLimit
        {
            get { return _creditLimit; }
            set { _creditLimit = value; }
        }

        public virtual decimal DefaultTaxRate
        {
            get { return _defaultTaxRate; }
            set { _defaultTaxRate = value; }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Role EmployeeRole
        {
            get { return _employeeRole; }
            set { _employeeRole = value; }
        }

        public virtual IList<PurchaseOrder> PurchaseOrders
        {
            get
            {
                if (_purchaseOrders == null)
                {
                    _purchaseOrders = new List<PurchaseOrder>();
                }
                return _purchaseOrders;
            }
            set { _purchaseOrders = value; }
        }

        public virtual IList<Pay> Pays
        {
            get
            {
                if (_pays == null)
                {
                    _pays = new List<Pay>();
                }
                return _pays;
            }
            set { _pays = value; }
        }

        public virtual IList<PurchaseReturn> PurchaseReturns
        {
            get
            {
                if (_purchaseReturns == null)
                {
                    _purchaseReturns = new List<PurchaseReturn>();
                }
                return _purchaseReturns;
            }
            set { _purchaseReturns = value; }
        }

        public virtual IList<StockInOut> StockIns
        {
            get
            {
                if (_stockIns == null)
                {
                    _stockIns = new List<StockInOut>();
                }
                return _stockIns;
            }
            set { _stockIns = value; }
        }



        #endregion
    }
    #endregion
}